<?php echo $this->load->view('meta'); ?>
<link rel="stylesheet" href="<?=base_url()?>css/admin.css" type="text/css" media="screen" />
<title>xa-ncsu | blog</title>
<link rel="stylesheet" href="<?=base_url()?>css/impromptu.css" type="text/css" media="screen" />
<script type="text/javascript" src="<?=base_url();?>js/jquery-impromptu.1.2.js"></script>
<script>
function vhconfirm(v,m)
        {
            if( v )
            {
                var f =  document.createElement("form");document.body.appendChild(f);f.method = "POST";f.action = $("#" + v ).attr( "href" );f.submit();
            } else
            {
                return false;
            }
        }
</script>
<?php echo $this->load->view('header'); ?>
<ul class="nav-list">
	<li><?=anchor('blog', 'view blog');?></li>
	<li class="last"><?=anchor('blog/publish', 'create a new entry');?></li>
</ul>
<?php if ($posts->num_rows() > 0): ?>
<table>	
	<tr>
		<th>title</th>
		<th>author</th>
		<th>posted</th>
		<th>access</th>
		<th>status</th>
		<th>comments</th>
		<th>actions</th>
	</tr>
<?php foreach ($posts->result() as $post): ?>
<tr>
	<td><?=anchor('blog/post/'.$post->id, $post->title);?></td>
	<td><?=$post->author?></td>
	<td><?=$post->posted?></td>
	<td><?=$post->public?></td>
	<td><?=$post->published?></td>
	<td><?=anchor('admin/blog_comments/'.$post->id, $post->num_comments);?></td>
	<td><a href="<?=site_url();?>blog/editPost/<?=$post->id?>"><img src="<?=base_url();?>img/icons/page_edit.png" alt="Edit Post" /></a>
		<a href="<?=site_url();?>blog/deletePost/<?=$post->id?>" id="conf<?=$post->id?>" onclick="$.prompt('Delete Post?',{callback: vhconfirm, buttons: { Yes : 'conf<?=$post->id?>', No : false}}); return false;">
			<img src="<?=base_url();?>img/icons/delete.png" alt="Delete Post" title="Delete Post" /></a>
	</td>
</tr>
<?php endforeach; ?>
<?php endif; ?>
</table>
<?php echo $this->load->view('footer'); ?>